package com.Test;

import java.util.*;

public class BorderSort {

    public static void main(String[] args) {

        String str = "AABBCADDDACCCCCC";

        System.out.println(filterCode2(str));

    }

    public static String filterCode2(String str) {

        List list = new ArrayList();

        for (int i = 0; i < str.length(); i++) {

            list.add(str.charAt(i) + "");// 这里就是使用字符串存入到list中，

        }

        for (int m = 0; m < list.size() - 1; m++) {

            if (list.get(m).equals(list.get(m + 1))) {

                list.remove(m + 1);

                list.remove(m);

                m--;

            }

        }

        StringBuffer sb = new StringBuffer();

        String str3 = "";

        for (int j = 0; j < list.size(); j++) {

                str3 = sb.append(list.get(j)).toString();

        }

        return str3;

    }

}
